Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process non-language pragma nodes in templates #24183

Merged
merged 6 commits into from
Oct 7, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Sep 26, 2024

fixes #24186

When encountering pragma nodes in templates, if it's a language pragma, we don't process the name, and only any values if they exist. If it's not a language pragma, we process the full node. Previously only the values of colon expressions were processed.

To make this simpler, whichPragma is patched to consider bracketed hint/warning etc pragmas like {.hint[HintName]: off.} as being a pragma of kind wHint rather than an invalid pragma which would have to be checked separately. From looking at the uses of whichPragma this doesn't seem like it would cause problems.

Generics have the same problem (causing #18649), but to make it work we need to make sure the templates/macros don't get evaluated or get evaluated correctly (i.e. passing the proc node as the final argument), either with #23094 or by completely disabling template/macro evaluation when processing the pragma node, which would also cover {.pragma.} templates.

@metagn metagn changed the title test full semming pragma nodes in templates process non-language pragma nodes in templates Sep 26, 2024
@metagn metagn marked this pull request as ready for review September 26, 2024 20:37
@Araq Araq merged commit 911cef1 into nim-lang:devel Oct 7, 2024
19 checks passed
Copy link
Contributor

github-actions bot commented Oct 7, 2024

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 911cef1

Hint: mm: orc; opt: speed; options: -d:release
174993 lines; 8.142s; 653.508MiB peakmem

metagn added a commit to metagn/Nim that referenced this pull request Oct 7, 2024
Araq pushed a commit that referenced this pull request Oct 7, 2024
fixes #18649, refs #24183

Same as in #24183 for templates, we now process pragma nodes in generics
so that macro symbols are captured and the pragma arguments are checked,
but ignoring language pragma keywords.

A difference is that we cannot process call nodes as is, we have to
process their children individually so that the early untyped
macro/template instantiation in generics does not kick in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pragma nodes in templates are completely unprocessed
2 participants